/*
Starting with 3.0,
express applications have become request handler functions that you pass to http or http Server instances.
         ↑ 即 const app = require('express')()
You need to pass the Server to socket.io
, and not the express application function.

Also make sure to call .listen on the server, not the app.
*/
const app = require('express')();
const server = require('http').createServer(app);
const io = require('socket.io')(server);
io.on('connection', (client) => {
  /* … */
});
server.listen(3000);
